<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitZhuliRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 助力活动
        Schema::create('zhuli_launch_records', function (Blueprint $table) {

            $table->comment = '助力发起表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->integer('user_id')->index()->comment('用户id');
            $table->integer('activity_id')->index()->comment('助力活动id');

            $table->integer('support_user_total')->index()->comment('助力用户总数');

            $table->timestamp('launched_at')->comment('发起时间');
            $table->timestamp('end_at')->nullable()->comment('预计失效时间');
            $table->timestamp('completed_at')->nullable()->comment('完成时间');

            $table->tinyInteger('status')->index()->default(1)->nullable()->comment('1为进行中  2为已完成  3为超时失效  4为系统终止');

            // $table->json('support_users')->comment('助力记录');

            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('zhuli_support_records', function (Blueprint $table) {

            $table->comment = '助力表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->integer('user_id')->index()->comment('用户id');
            $table->integer('activity_id')->index()->comment('助力活动id');
            $table->integer('launch_record_id')->index()->comment('助力活动id');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
